package org.megha.blog.example.selenium;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

/** 
 * Searches for a given string on yahoo.com.
 * (just an example to show how selenium client is used.)
 */
public class YahooSearch {

	// searches for the given string and prints the top two results
	public void searchFor(String string) {
		Selenium selenium = new DefaultSelenium("LOCALHOST", 4444, "*firefox", "http://www.yahoo.com/");
		selenium.start();
		selenium.open("/");
		selenium.waitForPageToLoad("30000");
		selenium.type("name=p", string);
		selenium.click("id=search-submit");
		selenium.waitForPageToLoad("30000");
		// TODO: do something with the results
		selenium.close();
		selenium.stop();
	}
	
	public static void main(String[] args) {
		YahooSearch search = new YahooSearch();
		search.searchFor("google");
	}
}
